In optics, depth of field (DOF) refers to the distance between the nearest and farthest objects in a viewing window that appear acceptably sharp in an image in a video game, movie or a photograph for example. The DOF effect can be simulated in computer graphics, e.g. based on a blur algorithm. Control over depth of field is an important artistic tool that can be used to emphasize the subject of an image.
Using diffusion equations to compute blurred image became quite popular with the development of computational power of graphic processors. The diffusion method simulates color distribution in an original image with varying blur radii as a function of the depth. This is typically done using an analogy of temperature field distribution on a 2D plate with non-uniform conductivity. FIG. 1A shows a diffusion equation that can be used to simulate DOF effect in accordance with the prior art. In such a simulation, equations may be discretized and solved using an alternating direction implicit (ADI) method in a single time step. The main property of diffusion approaches is that they can respect edges and depth discontinuity in the scene at the same time using varying filter size for blurring.
In real life, DOF blur naturally comes from a camera aperture which usually has a polygon shape. The polygon shape blur with emphasized bright features are referred to as a “Bokeh effect.” FIG. 1B illustrates the Bokeh effect created by a camera in a photograph. The hexagons bright spots in the background render the Bokeh effect in the photograph. In general, Gaussian-like blur operates well for averaging a scene with no brightness spikes. The Bokeh effect becomes almost a standard process in realistic image processing due to its natural presence in movies. So this is an important feature which needs to be addressed in almost any realistic looking depth-of-field technique. However, due to their inherent limitations, diffusion equations alone can only produce Gaussian-life blur that lacks a polygon shape or selectively highlighted bright spots in the image. In other words, diffusion equations do not produce good quality Bokeh effect objects in image processing.
Other DOF techniques include convolutions based on gather DOF algorithms and scatter DOF algorithms. FIG. 1C illustrates the principle of using gather algorithms to produce DOF effects in accordance with the prior art. Such algorithms generally involve computing the final color by performing convolution with a filter kernel featuring a size determined by the circle of confusion (CoC) and a shape of a polygon. FIG. 1D illustrates the principle of using scatter algorithms to produce DOF effects with a polygon filter in accordance with the prior art. The scatter algorithms involve setting up a quad with the Bokeh texture and rendering the quad with additive blending.
In the context of computer games or other application programs that often call for real-time image or video processing, computing efficiency and performance are important factors contributing to high quality visual effects.
Fast Fourier Transform (FFT)-based convolution is an important tool for generating fixed kernel shape blurs of the image. Graphic processors are very suitable for FFT and there are many efficient implementations of FFT using different application program interfaces (APIs). In general FFT blurs are much faster than their alternatives that are based on gather or scatter algorithms. However it's applications in depth-of-field effect techniques are underdeveloped due to restriction on the fixed kernel shape.